package com.zwj.mapstruct.entity.mapper;

import com.zwj.mapstruct.entity.dto.PigDto;
import com.zwj.mapstruct.entity.pojo.Pig;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface PigMapper {
    PigMapper MAPPER = Mappers.getMapper(PigMapper.class);

    //属性名称一致时，可以省略
    @Mappings({
            @Mapping(source = "id", target = "id"),
            @Mapping(source = "name", target = "name"),
            @Mapping(source = "age", target = "age")
    })
    PigDto from(Pig pig);
}